package com.mit.wx.wx.dto;

import com.mit.wx.util.WxXmlUtil;
import com.mit.wx.util.xml.CDataConverter;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import org.apache.commons.lang3.StringEscapeUtils;

/**
 * @author 郭文梁
 * <p>Create by 郭文梁</p>
 * <p>FOR:微信消息实体 </p>
 */
@Data
@XStreamAlias("xml")
public class TargetMessage implements XmlConvertible {
    @XStreamAlias("ToUserName")
    @XStreamConverter(CDataConverter.class)
    private String toUserName;
    @XStreamAlias("FromUserName")
    @XStreamConverter(CDataConverter.class)
    private String fromUserName;
    @XStreamAlias("CreateTime")
    private String createTime;
    @XStreamAlias("MsgType")
    @XStreamConverter(CDataConverter.class)
    private String msgType;

    @Override
    public String toXML() {
        return StringEscapeUtils.unescapeXml(WxXmlUtil.toXML(this));
    }
}
